package com.example.springboot.service;

import com.example.springboot.mapper.WorkOrderDao;
import com.example.springboot.pojo.WorkOrder;
import com.example.springboot.pojo.Workshop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service("workOrderService")
public class WorkOrderServiceImpl {
    @Autowired
    WorkOrderDao workOrderDao;

    public boolean addWorkOrder(WorkOrder workOrder) {
        if(workOrderDao.queryById(workOrder.getId())!=null)
            return false;
        workOrder.setStart_time(new Date());
        workOrderDao.addWorkOrder(workOrder);
        return true;
    }


    public WorkOrder queryById(int id) {
        return workOrderDao.queryById(id);
    }


    public boolean deleteById(int id) {
        if(workOrderDao.queryById(id)==null)
            return false;
        workOrderDao.deleteById(id);
        return true;
    }


    public List<WorkOrder> getWorkOrderList() {

        return workOrderDao.getWorkOrderList();
    }


    public boolean updateById(WorkOrder workOrder) {
        if(workOrderDao.queryById(workOrder.getId())==null)
            return false;
        workOrderDao.updateById(workOrder);
        return true;
    }


    public List<WorkOrder> getWorkOrderListByCondition(Map<String, String> map) {
        List<WorkOrder> workOrderList = workOrderDao.getWorkOrderListByCondition(map);
        return workOrderList;
    }

}
